package com.hsogoo.study.spring.resource;

import java.io.IOException;
import java.io.InputStream;

import org.springframework.core.io.Resource;

/**
 * Created by za-huangsaigang on 2018/9/17.
 */
public class ResourceTemplate {

    protected void dumpStream(Resource resource) {
        InputStream is = null;
        try {
            //1.获取文件资源 
            is = resource.getInputStream();
            //2.读取资源 
            byte[] descBytes = new byte[is.available()];
            is.read(descBytes);
            System.out.println(new String(descBytes));
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                //3.关闭资源 
                is.close();
            } catch (IOException e) {
            }
        }
    }
}
